using UnityEngine;

namespace Game.XH
{
	public static class XHTransform
	{
		public static void SetObjectActive(this Transform trans, bool val)
		{
			if (trans != null)
			{
				trans.gameObject.SetActive(val);
			}
		}

		public static float GetLocalScaleY(this Transform trans)
		{
			if (trans != null)
			{
				return trans.localScale.y;
			}
			return 1f;
		}

		public static void SetLocalScaleX(this Transform trans, float val)
		{
			if (trans != null)
			{
				trans.localScale = new Vector3(val, trans.localScale.y, trans.localScale.z);
			}
		}

		public static void SetLocalScaleY(this Transform trans, float val)
		{
			if (trans != null)
			{
				trans.localScale = new Vector3(trans.localScale.x, val, trans.localScale.z);
			}
		}

		public static void SetLocalScaleXY(this Transform trans, float x, float y)
		{
			if (trans != null)
			{
				trans.localScale = new Vector3(x, y, trans.localScale.z);
			}
		}

		public static void SetLocalScaleXYZ(this Transform trans, float x, float y, float z)
		{
			if (trans != null)
			{
				trans.localScale = new Vector3(x, y, z);
			}
		}

		public static void SetX(this Transform trans, float x)
		{
			if (trans != null)
			{
				trans.position = new Vector3(x, trans.position.y, trans.position.z);
			}
		}

		public static void SetY(this Transform trans, float y)
		{
			if (trans != null)
			{
				trans.position = new Vector3(trans.position.x, y, trans.position.z);
			}
		}

		public static void SetXY(this Transform trans, float x, float y)
		{
			if (trans != null)
			{
				trans.position = new Vector3(x, y, trans.position.z);
			}
		}

		public static void SetZ(this Transform trans, float z)
		{
			if (trans != null)
			{
				trans.position = new Vector3(trans.position.x, trans.position.y, z);
			}
		}

		public static void SetLocalX(this Transform trans, float x)
		{
			if (trans != null)
			{
				trans.localPosition = new Vector3(x, trans.localPosition.y, trans.localPosition.z);
			}
		}

		public static void SetLocalY(this Transform trans, float y)
		{
			if (trans != null)
			{
				trans.localPosition = new Vector3(trans.localPosition.x, y, trans.localPosition.z);
			}
		}

		public static void SetLocalZ(this Transform trans, float z)
		{
			if (trans != null)
			{
				trans.localPosition = new Vector3(trans.localPosition.x, trans.localPosition.y, z);
			}
		}

		public static void SetLocalXY(this Transform trans, float x, float y)
		{
			if (trans != null)
			{
				trans.localPosition = new Vector3(x, y, trans.localPosition.z);
			}
		}

		public static void SetLocalXY(this Transform trans, Vector2 position)
		{
			if (trans != null)
			{
				trans.localPosition = new Vector3(position.x, position.y, trans.localPosition.z);
			}
		}

		public static void SetLocalXYZ(this Transform trans, float x, float y, float z)
		{
			if (trans != null)
			{
				trans.localPosition = new Vector3(x, y, z);
			}
		}

		public static void SetLocalRotationZ(this Transform trans, float z)
		{
			if (trans != null)
			{
				trans.localEulerAngles = new Vector3(trans.localEulerAngles.x, trans.localEulerAngles.y, z);
			}
		}

		public static void SetSpriteColor(this SpriteRenderer sprite, Color32 val)
		{
			if (sprite != null)
			{
				sprite.color = val;
			}
		}

		public static void SetSpriteAlpha(this SpriteRenderer sprite, float val)
		{
			if (sprite != null)
			{
				sprite.color = new Color(sprite.color.r, sprite.color.g, sprite.color.b, val);
			}
		}
	}
}
